<fieldset id="fd1" style="width:80%;margin:5px;">
	<legend><span>潜在客户信息查询</span></legend>
	<div class="fieldset-body">
		<table class="form-table" border="0" cellpadding="1" cellspacing="2">
			<tr>
				<!--  
				<td class="form-label" style="width:80px;">顾客类型:</td>
				<td style="width:150px"><input id="types" class="mini-combobox" textField="name" valueField="id" data="JS.CONST[1]" allowInput="true" style="width:100%;" /></td>
				-->
				<td class="form-label" style="width:80px;">所在区域：</td>
				<td style="width:150px"><input id="area" expandOnLoad="true" class="mini-treeselect" url="/common/area" multiSelect="false" textField="name" valueField="id" parentField="parent" checkRecursive="true" showFolderCheckBox="true" style="width:150px;" onenter="onKeyEnter"/></td>
				<td class="form-label" style="width:80px;">客户序列号:</td>
				<td style="width:150px"><input id="user" class="mini-textbox" emptyText="请输入登录账户" style="width:100%;" onenter="onKeyEnter"/></td>
				<td class="form-label" style="width:80px;">顾客昵称:</td>
				<td style="width:150px"><input id="name" class="mini-textbox" emptyText="请输入昵称" style="width:100%;" onenter="onKeyEnter"/></td>
				<td style="width:150px"><a class="mini-button" id="search" iconCls="icon-search">查询...</a></td>
			</tr>
		</table>
	</div>
</fieldset>
<div class="mini-toolbar" style="padding:0px;margin:6px 0px 0px 0px;border-bottom:0;width:100%;">
	<table style="width:100%;">
		<tr>
			<td style="width:100%;">
				<a class="mini-button" iconCls="icon-ok" id="buttonStart" plain="true">启用</a>
				<a class="mini-button" iconCls="icon-lock" id="buttonEnd" plain="true">禁用</a>
				<span class="separator"></span>
                <a class="mini-button" iconCls="icon-ok" id="verifyYes" plain="true">审核通过</a>
                <a class="mini-button" iconCls="icon-remove" id="verifyNo" plain="true">审核不通过</a>
                <span class="separator"></span>
				<a class="mini-button" iconCls="icon-upload" id="buttonUp" plain="true">升级为顾客</a>
				<span class="separator"></span>
				<a class="mini-button" iconCls="icon-search" onClick="CustomerInfo('id')" plain="true">查看顾客详情</a>
				<span class="separator"></span>
				<a class="mini-button" iconCls="icon-filter" id="buttonReload" plain="true">重置密码(密码：888888)</a>
			</td>
		</tr>
	</table>
</div>
<div id="grid1" class="mini-datagrid" allowAlternating="true" idField="id" pageSize="20" style="width:100%;height:80%;" url="/customer/customerList" >
	<!-- frozenStartColumn="0" frozenEndColumn="3" -->
	<div property="columns">
		<div type="indexcolumn" headerAlign="center">编号</div>
		<div field="area" width="80" headerAlign="center" allowSort="true">所在区域</div>
		<div field="name" width="100" headerAlign="center" allowSort="true">昵称</div>
		<div field="stopname" width="40" headerAlign="center" allowSort="true" align="center">类型</div>
		<div field="verify" width="70" headerAlign="center" allowSort="true" align="center">是否审核</div>
		<div field="users" width="80" headerAlign="center" allowSort="true">客户序列号</div>
		<div field="level" width="40" headerAlign="center" allowSort="true">等级<input property="editor" class="mini-combobox" textField="name" valueField="name" data="JS.CONST[1]" allowInput="true" style="width:100%;" /></div>
		<!--  
		<div field="sex" width="100" headerAlign="center" allowSort="true">性别<input property="editor" class="mini-combobox" textField="name" valueField="id" data="JS.CONST[6]" allowInput="true" style="width:100%;" /></div>
		-->
		<div header="顾客联系信息" headerAlign="center">
			<div property="columns">
				<div field="mobile_phone" width="80" headerAlign="center">手机号</div>
				<div field="tel" width="110" headerAlign="center">座机号</div>
				<div field="email" width="110" headerAlign="center">邮箱</div>
			</div>
		</div>
		<div field="remark" width="120" headerAlign="center">备注<input property="editor" class="mini-textarea" emptyText="请输入备注" style="width:100%;height:40px;"/></div>
		<div field="updated" width="70" headerAlign="center" dateFormat="yyyy-MM-dd" allowSort="true">更新日期</div>
		<div name="action" width="100" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>
	</div>
</div>
<script type="text/javascript">
mini.parse();
var urlDel = "/customer/customerDel";
var urlUpd = "/customer/customerUpd";
var grid = mini.get("grid1");
grid.load({types:0});

$("#search").click(function(){
	grid.load({types:0,user:mini.get("user").getValue(),area:mini.get("area").getValue(),name:mini.get("name").getValue()});
});

$("#buttonStart").click(function(){
	var row = grid.getSelected();
	if (row != null) {
		parent.$.dooDialog.confirm("你确定要启用这个顾客吗？",function(){
			$.post('/customer/stopStart',{id:row.sid},function(data){
				if(data.code=='OK'){
					grid.load({types:0,user:mini.get("user").getValue(),area:mini.get("area").getValue(),name:mini.get("name").getValue()});
				}else{
					parent.$.dooDialog.alert('启用顾客失败！');
					return false;
				}
			},'json');
		});
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
});

$("#buttonEnd").click(function(){
	var row = grid.getSelected();
	if (row != null) {
		parent.$.dooDialog.confirm("你确定要禁用这个顾客吗？",function(){
			$.post('/customer/stopEnd',{id:row.sid},function(data){
				if(data.code=='OK'){
					grid.load({types:0,user:mini.get("user").getValue(),area:mini.get("area").getValue(),name:mini.get("name").getValue()});
				}else{
					parent.$.dooDialog.alert('禁用顾客失败！');
					return false;
				}
			},'json');
		});
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
});

$("#verifyYes").click(function(){
    var row = grid.getSelected();
    if (row != null) {
        parent.$.dooDialog.confirm("你确定要将这个客户设置为已通过吗？",function(){
            $.post('/customer/verify/?typesss=nos',{id:row.cid,types:1},function(data){
                if(data.code=='OK'){
                    grid.load({types:0,user:mini.get("user").getValue(),area:mini.get("area").getValue(),name:mini.get("name").getValue()});
                }else{
                    parent.$.dooDialog.alert('审核顾客失败！');
                    return false;
                }
            },'json');
        });
    } else {
        parent.$.dooDialog.alert("请选中一条记录");
    }
});

$("#verifyNo").click(function(){
    var row = grid.getSelected();
    if (row != null) {
        parent.$.dooDialog.confirm("你确定要将这个客户设置为未通过吗？",function(){
            $.post('/customer/verify/?typesss=nos',{id:row.cid,types:0},function(data){
                if(data.code=='OK'){
                    grid.load({types:0,user:mini.get("user").getValue(),area:mini.get("area").getValue(),name:mini.get("name").getValue()});
                }else{
                    parent.$.dooDialog.alert('审核顾客失败！');
                    return false;
                }
            },'json');
        });
    } else {
        parent.$.dooDialog.alert("请选中一条记录");
    }
});

$("#buttonReload").click(function(){
	var row = grid.getSelected();
	if (row != null) {
		parent.$.dooDialog.confirm("你确定要重置这个顾客的密码吗？",function(){
			$.post('/customer/pwdReload',{id:row.sid},function(data){
				if(data.code=='OK'){
					grid.load({types:0,user:mini.get("user").getValue(),area:mini.get("area").getValue(),name:mini.get("name").getValue()});
					parent.$.dooDialog.alert('密码重置成功！');
				}else{
					parent.$.dooDialog.alert('密码重置失败！');
					return false;
				}
			},'json');
		});
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
});

$("#buttonUp").click(function(){
	var row = grid.getSelected();
	if (row != null) {
		$.post('/customer/typesUp',{id:row.cid},function(data){
			if(data.code=='OK'){
				grid.load({types:0,user:mini.get("user").getValue(),area:mini.get("area").getValue(),name:mini.get("name").getValue()});
			}else{
				parent.$.dooDialog.alert('潜在客户升级为客户失败！');
				return false;
			}
		},'json');
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
});
function onKeyEnter(e) {
	grid.load({types:0,user:mini.get("user").getValue(),area:mini.get("area").getValue(),name:mini.get("name").getValue()});
}
</script>